package org.UDPDemo;

import java.io.IOException;
import java.net.*;

public class sendMessageDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket=new DatagramSocket();
        String str="UDP协议传输数据案例";
        int port=10086;
        InetAddress byName = InetAddress.getByName("127.0.0.1");
        byte[] bytes = str.getBytes();
        DatagramPacket datagramPacket=new DatagramPacket(bytes,bytes.length,byName,port);
        datagramSocket.send(datagramPacket);
        datagramSocket.close();
    }
}